package org.idontknow.singleton;

import java.lang.CloneNotSupportedException;

class Test implements Runnable{

  private int id;

  public Test(int _id) {
    id = _id;
  }

  public static void main(String[] args) {
    //    for(int i = 0; i < 10000; i++)
    //      new Thread(new Test(i)).start();
    SingletonObject obj = SingletonObject.getSingletonObject();
    SingletonObject duplication = SingletonObject.getSingletonObject();
    System.out.println(obj == duplication);
    try{
      obj.clone();
    } catch (CloneNotSupportedException e) {
      System.out.println("ok, anyway i made a try...");
    }
    //    SingletonObject sglObj = SingletonObject.getSingletonObject();
    //    SingletonObject sglObj2 = SingletonObject.getSingletonObject();
  }

  public void run() {
    //    System.out.println("coucou~~im thread no." + this.getId() + ", im gonna create a singleton...");
    SingletonObject.getSingletonObject();
  }

  public int getId() {
    return id;
  }
}
